package com.bishe.service;

import com.bishe.dao.ProjectDao;
import com.bishe.entity.Project;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectService {
    @Autowired
    private ProjectDao projectDao;
    //添加商品基本信息
    public void insert1(Project project){
        project.setStatus(1);
        projectDao.insert(project);
    }

    //分页查询
    public List<Project> selectByPage(int page, int limit){
        int start = (page-1)*limit;
        return projectDao.SelectByPage(start,limit);
    }

    //计算总页数
    public long getPageCount(int limit){
        //获取总条数
        long count = projectDao.selectCount();
        //根据总条数计算总页数
        return count%limit==0?count/limit:(count/limit)+1;
    }

}
